package interfacetest

import "fmt"

func Execute() {
	products := []Product{}
	products = append(products, &Keyboard{name: "keyboard", quantity: 2, price: 10})
	products = append(products, &Mouse{name: "mouse", quantity: 3, price: 20})

	for _, p := range products {
		p.getQuantity()
		p.calculatePrice()
	}
}

type Product interface {
	calculatePrice() int
	getQuantity() int
}

type Keyboard struct {
	name     string
	quantity int
	price    int
}

func (keyboard *Keyboard) calculatePrice() int {
	payment := keyboard.price * keyboard.quantity

	fmt.Printf("%v payment: %v\n", keyboard.name, payment)
	return payment
}

func (keyboard *Keyboard) getQuantity() int {
	fmt.Printf("keyboard.quantity: %v\n", keyboard.quantity)
	return keyboard.quantity
}

type Mouse struct {
	name     string
	quantity int
	price    int
}

func (mouse *Mouse) calculatePrice() int {
	payment := mouse.price * mouse.quantity

	fmt.Printf("%v payment: %v\n", mouse.name, payment)
	return payment
}

func (mouse *Mouse) getQuantity() int {
	fmt.Printf("mouse.quantity: %v\n", mouse.quantity)
	return mouse.quantity
}
